home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Sample Code / MoreFiles 1.1.1 / DirectoryCopy.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-22  |  6.4 KB  |  179 lines  |  [TEXT/KAHL]

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    DirectoryCopy: A robust, general purpose directory copy routine.
  5. **
  6. **    by Jim Luther, Apple Developer Technical Support
  7. **
  8. **    File:        DirectoryCopy.h
  9. **
  10. **    Copyright © 1992-1994 Apple Computer, Inc.
  11. **    All rights reserved.
  12. **
  13. **    You may incorporate this sample code into your applications without
  14. **    restriction, though the sample code has been provided "AS IS" and the
  15. **    responsibility for its operation is 100% yours.  However, what you are
  16. **    not permitted to do is to redistribute the source as "DSC Sample Code"
  17. **    after having made changes. If you're going to re-distribute the source,
  18. **    we require that you make it clear in the source that the code was
  19. **    descended from Apple Sample Code, but that you've made changes.
  20. */
  21.  
  22. #ifndef __DIRECTORYCOPY__
  23. #define __DIRECTORYCOPY__
  24.  
  25. #ifndef __TYPES__
  26. #include <Types.h>
  27. #endif
  28.  
  29. #ifndef __ERRORS__
  30. #include <Errors.h>
  31. #endif
  32.  
  33. #ifndef __MEMORY__
  34. #include <Memory.h>
  35. #endif
  36.  
  37. #ifndef __OSUTILS__
  38. #include <OSUtils.h>
  39. #endif
  40.  
  41. #ifndef __FILES__
  42. #include <Files.h>
  43. #endif
  44.  
  45. #ifndef __MOREFILES__
  46. #include "MoreFiles.h"
  47. #endif
  48.  
  49. #ifndef __MOREFILESEXTRAS__
  50. #include "MoreFilesExtras.h"
  51. #endif
  52.  
  53. #ifndef __FILECOPY__
  54. #include "FileCopy.h"
  55. #endif
  56.  
  57. enum
  58. {
  59.     getNextItemOp            = 1,    /* couldn't access items in this directory - no access privileges */
  60.     copyDirCommentOp        = 2,    /* couldn't copy directory's Finder comment */
  61.     copyDirAccessPrivsOp    = 3,    /* couldn't copy directory's AFP access privileges */
  62.     copyDirFMAttributesOp    = 4,    /* couldn't copy directory's File Manager attributes */
  63.     dirCreateOp                = 5,    /* couldn't create destination directory */
  64.     fileCopyOp                = 6        /* couldn't copy file */
  65. };
  66.  
  67. /*****************************************************************************/
  68.  
  69. typedef    pascal    Boolean    (*CopyErrProcPtr) (OSErr error,
  70.                                            short failedOperation,
  71.                                            short srcVRefNum,
  72.                                            long srcDirID,
  73.                                            StringPtr srcName,
  74.                                            short dstVRefNum,
  75.                                            long dstDirID,
  76.                                            StringPtr dstName);
  77. /*    This is the prototype for the CopyErrProc function DirectoryCopy
  78.     calls if an error condition is detected sometime during the copy.  If
  79.     CopyErrProc returns true, then DirectoryCopy attempts to continue with
  80.     the directory copy operation.  If CopyErrProc returns false, then
  81.     DirectoryCopy stops the directory copy operation.
  82.  
  83.     error            input:    The error result code that caused CopyErrProc to
  84.                             be called.
  85.     failedOperation    input:    The operation that returned an error to
  86.                             DirectoryCopy.
  87.     srcVRefNum        input:    Source volume specification.
  88.     srcDirID        input:    Source directory ID.
  89.     srcName            input:    Source file or directory name, or nil if
  90.                             srcDirID specifies the directory.
  91.     dstVRefNum        input:    Destination volume specification.
  92.     dstDirID        input:    Destination directory ID.
  93.     dstName            input:    Destination file or directory name, or nil if
  94.                             dstDirID specifies the directory.
  95. */
  96.  
  97. /*****************************************************************************/
  98.  
  99. pascal    OSErr    DirectoryCopy(short srcVRefNum,
  100.                               long srcDirID,
  101.                               StringPtr srcName,
  102.                               short dstVRefNum,
  103.                               long dstDirID,
  104.                               StringPtr dstName,
  105.                               Ptr copyBufferPtr,
  106.                               long copyBufferSize,
  107.                               Boolean preflight,
  108.                               CopyErrProcPtr copyErrHandler);
  109. /*    Use DirectoryCopy to make a copy of a directory structure in a new
  110.     location.  If copyBufferPtr <> NIL, it points to a buffer of
  111.     copyBufferSize that is used to copy files data.  The larger the
  112.     supplied buffer, the faster the copy.  If copyBufferPtr = NIL, then this
  113.     routine allocates a buffer in the application heap. If you pass a
  114.     copy buffer to this routine, make its size a multiple of 512
  115.     ($200) bytes for optimum performance.
  116.     
  117.     srcVRefNum        input:    Source volume specification.
  118.     srcDirID        input:    Source directory ID.
  119.     srcName            input:    Source directory name, or nil if
  120.                             srcDirID specifies the directory.
  121.     dstVRefNum        input:    Destination volume specification.
  122.     dstDirID        input:    Destination directory ID.
  123.     dstName            input:    Destination directory name, or nil if
  124.                             dstDirID specifies the directory.
  125.     copyBufferPtr    input:    Points to a buffer of copyBufferSize that
  126.                             is used the i/o buffer for the copy or
  127.                             nil if you want DirectoryCopy to allocate its
  128.                             own buffer in the application heap.
  129.     copyBufferSize    input:    The size of the buffer pointed to
  130.                             by copyBufferPtr.
  131.     preflight        input:    If true, DirectoryCopy makes sure there are
  132.                             enough allocation blocks on the destination
  133.                             volume to hold the directory's files before
  134.                             starting the copy.
  135.     copyErrHandler    input:    A pointer to the routine you want called if an
  136.                             error condition is detected during the copy, or
  137.                             nil if you don't want to handle error conditions.
  138.                             Error handling is recommended...
  139. */
  140.  
  141. /*****************************************************************************/
  142.  
  143. pascal    OSErr    FSpDirectoryCopy(const FSSpec *srcSpec,
  144.                                  const FSSpec *dstSpec,
  145.                                  Ptr copyBufferPtr,
  146.                                  long copyBufferSize,
  147.                                  Boolean preflight,
  148.                                  CopyErrProcPtr copyErrHandler);
  149. /*    Use FSpDirectoryCopy to make a copy of a directory structure in a new
  150.     location.  If copyBufferPtr <> NIL, it points to a buffer of
  151.     copyBufferSize that is used to copy files data.  The larger the
  152.     supplied buffer, the faster the copy.  If copyBufferPtr = NIL, then this
  153.     routine allocates a buffer in the application heap. If you pass a
  154.     copy buffer to this routine, make its size a multiple of 512
  155.     ($200) bytes for optimum performance.
  156.     
  157.     srcSpec            input:    An FSSpec record specifying the directory to copy.
  158.     dstSpec            input:    An FSSpec record specifying destination directory
  159.                             of the copy.
  160.     copyBufferPtr    input:    Points to a buffer of copyBufferSize that
  161.                             is used the i/o buffer for the copy or
  162.                             nil if you want DirectoryCopy to allocate its
  163.                             own buffer in the application heap.
  164.     copyBufferSize    input:    The size of the buffer pointed to
  165.                             by copyBufferPtr.
  166.     preflight        input:    If true, FSpDirectoryCopy makes sure there are
  167.                             enough allocation blocks on the destination
  168.                             volume to hold the directory's files before
  169.                             starting the copy.
  170.     copyErrHandler    input:    A pointer to the routine you want called if an
  171.                             error condition is detected during the copy, or
  172.                             nil if you don't want to handle error conditions.
  173.                             Error handling is recommended...
  174. */
  175.  
  176. /*****************************************************************************/
  177.  
  178. #endif
  179.